
* Replication file
* "BREAKING OUT OF THE COUP TRAP: POLITICAL COMPETITION AND MILITARY COUPS IN LATIN AMERICA"
* By Fabrice Lehoucq and Anibal Perez-Linan
* Comparative Political Studies, vol. 47 no. 12 (2014)
**   Anibal Perez-Linan (asp27@pitt.edu) -  Jan 2013

* Change local path: 
cd "C:\Users\Anibal\Documents\1_Research\Published\2014.CPS\Replication"

use "1_Coup_Trap.dta", clear
xtset cc_cow year

log using "Results.txt", text replace

*** TABLE 2 ***

xtlogit y1 dur1 dur1_2    pgdp_1 gpgdp_1 ff_1i negretto regcoup2 DIFF liberal isi 
estimates store reg21
**  Smith
xtlogit y1 dur1 dur1_2 c1 pgdp_1 gpgdp_1 ff_1i negretto regcoup2 DIFF liberal isi 
estimates store reg22
** Mainwaring
xtlogit y1 dur1 dur1_2 c2 pgdp_1 gpgdp_1 ff_1i negretto regcoup2 DIFF liberal isi 
estimates store reg23
** Polity
xtlogit y1 dur1 dur1_2 c4 pgdp_1 gpgdp_1 ff_1i negretto regcoup2 DIFF liberal isi 
estimates store reg24

xml_tab reg21 reg22 reg23 reg24, format((S2100) (N2202)) /// 
    save("1_Tables.xls") ///
    below stats(N) sheet("Table2") stars(* 0.1 ** 0.05) replace

	
*** TABLES 3 and 4 ***

*** A - Frailty Models

** MODEL 3.1 - Smith
/* Note: Overconfidence-Corrected Critical t-value using Sidak correction for k = 4 is p = .987 */
set l 98.7

xtlogit y1 dur1 dur1_2 c1 dur1_c1 dur1_2_c1 pgdp_1 gpgdp_1 ff_1i negretto regcoup2 DIFF liberal isi 
estimates store reg31

* TABLE 4 (4.1.1)
/* 2 years after coup */
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c1] + 2*_b[dur1_2_c1]*2)*(0)  
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c1] + 2*_b[dur1_2_c1]*2)*(1) 
 
/* 20 years after coup */
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c1] + 2*_b[dur1_2_c1]*20)*(0)  
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c1] + 2*_b[dur1_2_c1]*20)*(1) 



** MODEL 3.2 - Mainwaring
xtlogit y1 dur1 dur1_2 c2 dur1_c2 dur1_2_c2 pgdp_1 gpgdp_1 ff_1i negretto regcoup2 DIFF liberal isi 
estimates store reg32
 
* TABLE 4 (4.1.2)
/* 2 years after coup */
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c2] + 2*_b[dur1_2_c2]*2)*(0)  
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c2] + 2*_b[dur1_2_c2]*2)*(1)  
/* 20 years after coup */
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c2] + 2*_b[dur1_2_c2]*20)*(0)  
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c2] + 2*_b[dur1_2_c2]*20)*(1) 



** MODEL 3.3 - Polity
/* Note: Overconfidence-Corrected Critical t-value for continuous variable from Esarey and Lawrence (2012) is 2.41 p = .992 */
set l 99.2

xtlogit y1 pgdp_1 gpgdp_1 ff_1i negretto regcoup2 DIFF liberal isi dur1 dur1_2 c4 dur1_c4 dur1_2_c4
estimates store reg33

* FIGURE 2
/* 2 years after coup */
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-10)  
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-9)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-8) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-7)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-6) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-5) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-4)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-3) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-2)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-1)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(0) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(1)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(2)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(3) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(4)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(5)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(6) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(7)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(8)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(9) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(10) 

/* 20 years after coup */
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-10)  
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-9)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-8) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-7)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-6) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-5) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-4)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-3) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-2)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-1)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(0) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(1)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(2)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(3) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(4)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(5)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(6) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(7)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(8)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(9) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(10) 

xml_tab reg31 reg32 reg33 , format((S2100) (N2202)) /// 
    save("1_Tables.xls") ///
    below stats(N) sheet("Table3_a") stars(* 0.1 ** 0.05) append
	
	
	
	
*** B - Fixed-Effects Models

** MODEL 3.4 - Smith
/* Note: Overconfidence-Corrected Critical p-value using Sidak correction is .987 */
set l 98.7

xtlogit y1 dur1 dur1_2 c1 dur1_c1 dur1_2_c1 pgdp_1 gpgdp_1 ff_1i negretto regcoup2 DIFF liberal isi, fe
estimates store reg41

* TABLE 4 (4.2.1)
/* 2 years after coup */
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c1] + 2*_b[dur1_2_c1]*2)*(0)  
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c1] + 2*_b[dur1_2_c1]*2)*(1)  
/* 20 years after coup */
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c1] + 2*_b[dur1_2_c1]*20)*(0)  
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c1] + 2*_b[dur1_2_c1]*20)*(1) 



** MODEL 3.5 - Mainwaring
xtlogit y1 dur1 dur1_2 c2 dur1_c2 dur1_2_c2 pgdp_1 gpgdp_1 ff_1i negretto regcoup2 DIFF liberal isi, fe
estimates store reg42

* TABLE 4 (4.2.2)
/* 2 years after coup */
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c2] + 2*_b[dur1_2_c2]*2)*(0)  
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c2] + 2*_b[dur1_2_c2]*2)*(1)  
/* 20 years after coup */
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c2] + 2*_b[dur1_2_c2]*20)*(0)  
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c2] + 2*_b[dur1_2_c2]*20)*(1) 



** MODEL 3.6 - Polity
/* Note: Overconfidence-Corrected Critical t-value from Esarey and Lawrence (2012) is 2.41 p = .992 */
set l 99.2

xtlogit y1 pgdp_1 gpgdp_1 ff_1i negretto regcoup2 DIFF liberal isi dur1 dur1_2 c4 dur1_c4 dur1_2_c4, fe
estimates store reg43

* FIGURE 3
/* 2 years after coup */
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-10)  
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-9)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-8) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-7)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-6) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-5) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-4)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-3) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-2)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(-1)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(0) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(1)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(2)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(3) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(4)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(5)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(6) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(7)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(8)
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(9) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*2) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*2)*(10) 

/* 20 years after coup */
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-10)  
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-9)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-8) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-7)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-6) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-5) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-4)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-3) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-2)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(-1)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(0) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(1)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(2)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(3) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(4)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(5)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(6) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(7)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(8)
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(9) 
nlcom  (_b[dur1] + 2*_b[dur1_2]*20) + (_b[dur1_c4] + 2*_b[dur1_2_c4]*20)*(10) 

xml_tab reg41 reg42 reg43 , format((S2100) (N2202)) /// 
    save("1_Tables.xls") ///
    below stats(N) sheet("Table3_b") stars(* 0.1 ** 0.05) append

log close
	
	


